import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
//import Qt.labs.settings
import QtCore

Window {
    width: 640
    height: 480
    visible: true
    title: qsTr("Hello World")

    SplitView {
        id: splitView
        anchors.fill: parent
        orientation: Qt.Horizontal

        // 添加子项
        Rectangle {
            width: 200
            color: "lightblue"
            Label {
                text: "Panel 1"
                anchors.centerIn: parent
            }
        }

        Rectangle {
            SplitView.fillWidth: true
            color: "lightgray"
            Label {
                text: "Panel 2 (fill item)"
                anchors.centerIn: parent
            }
        }

        Rectangle {
            width: 200
            color: "lightgreen"
            Label {
                text: "Panel 3"
                anchors.centerIn: parent
            }
        }
    }

    Settings {
        id: settings
        property var splitViewState
    }

    // 保存和恢复 SplitView 的状态
    Component.onCompleted: splitView.restoreState(settings.splitViewState)
    Component.onDestruction: settings.splitViewState = splitView.saveState()
}
